import { getOpRecommendUser } from '../../../../api/user'

Component({
  properties: {},

  data: {
    listQuery: {
      condition: {},
      pager: {
        page: 1,
        pageSize: 5
      }
    },
    list: [],
    current: 0
  },

  options: {
    styleIsolation: 'apply-shared'
  },

  lifetimes: {
    attached() {
      this.init()
    }
  },

  attached() {
    this.init()
  },

  methods: {
    init() {
      getOpRecommendUser().then(res => {
        if (res.length) {
          res.forEach(r => {
            if (r.honour.length > 3) {
              r.honour.splice(3, r.honour.length - 3)
            }
          })
        }
        this.setData({
          list: res
        })
      })
    },
    swiperChange(e) {
      this.setData({
        current: e.detail.current
      })
    },
    toTeacherDetail(e) {
      wx.navigateTo({
        url: '/packageA/pages/teacher/detail/detail?userId=' + e.currentTarget.dataset.id
      })
    }
  }
})
